var app=getApp()
Page({
  data: {
    userAccount: "",
    psw1: "",
    psw2: ""
  },
  onLoad:function(){
    wx.setNavigationBarTitle({
      title: '注册' 
    })
  },
  create_zhuce: function (e) {
    if(e.detail.value.password1!=e.detail.value.password2&&e.detail.value.password2!=null){
    wx.showToast({
      title: '密码不一致!',
      icon:'none',
    })
    }else{
      wx.request({
        url: app.globalData.url+'userRegisterAction',
      data: {
        userAccount: e.detail.value.username,
        userPwd: e.detail.value.password1,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
      },
      success(res) {
        // console.log(res.data)
        if(res.data){
          wx.showToast({
            title: '注册成功',
            icon:'none',
          })
          wx.reLaunch({
            url: '../login/login',
          })
        }else{
          wx.showToast({
            title: '用户名重复!',
            icon:'none',
          })
        }
      }
      })

  }

}
})
